﻿<Window x:Name="SelectorWindow"
        x:Class="BadHabit.Factory.Windows.TaskSelector"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"
        xmlns:props="clr-namespace:BadHabit.Factory.Properties"                                
        
        Title="TaskSelector"
        Width="300"
        SizeToContent="Height"
        Background="Transparent"
        WindowStyle="None"
        AllowsTransparency="True"                
        SnapsToDevicePixels="False"             
        ShowInTaskbar="False"           
        Topmost="True"      
        MouseLeave="selectorWindow_MouseLeave"        
        
    >
    
    <Window.Resources>
        <DataTemplate x:Key="TaskResumeTemplate">            
            
                        <Grid  ToolTip="{StaticResource TaskToolTip}" ToolTipService.InitialShowDelay="3000">
                
                    <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>                                
                            </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Style="{StaticResource TaskAlertImage}" Width="16" Height="16"/>
                
                            <TextBlock                     
                                Grid.Column="1" 
                            FontFamily="{StaticResource BasicFont}" FontSize="{StaticResource NeedToSeeFontSize}" Text="{Binding TaskName}" TextWrapping="Wrap">
                            
                    <TextBlock.Style>
                                <Style TargetType="TextBlock">                             
                                    <Style.Triggers>                                        
                                        <DataTrigger Binding="{Binding TaskType}" Value="4">
                                            <Setter Property="Foreground" Value="#FFAA60"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                
                        </TextBlock>
                
                

            </Grid>                        
            
        </DataTemplate>        
    </Window.Resources>

    <Border Style="{StaticResource FactoryMainWindowBorder}" Background="Transparent">
        <Grid Name="ContentGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border
                Grid.Row="0"           
                Style="{StaticResource FactoryWindowTitleBorder}"
                MaxHeight="80">

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="22"/>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="40"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" 
                           HorizontalAlignment="Left"
                           TextAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="0"
                           Text="{Binding ElementName=SelectorWindow, Path=FormatedWorkedTime}" Style="{StaticResource TaskSelectorTitleTimeTextBlock}"/>
                    <TextBlock Grid.Column="1" Text="{Binding TaskName}" Style="{StaticResource TaskSelectorTitleTextBlock}" VerticalAlignment="Top"/>
                    <Border Grid.Column="2" Background="{StaticResource DarkBrush}" CornerRadius="3" Margin="2" Cursor="Hand" >
                        <Image
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Source="/Images/TaskStatus/32x32/Task_Done.png" Width="24" Height="24" Stretch="Uniform"
                            ToolTip="{x:Static props:Resources.Close_this_task}"
                            MouseLeftButtonUp="TaskDone_MouseUp">                            
                        </Image>
                        <Border.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=SelectorWindow, Path=IsIdle}" Value="True">
                                        <Setter Property="Border.Visibility" Value="Hidden"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                    </Border>
                    
                </Grid>
            </Border>

            <ListBox   Name="listView"
                        Grid.Row="1"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        Background="{StaticResource TaskSelectorBackgroundBrush}"                
                        BorderThickness="1,0,1,1"
                        BorderBrush="{StaticResource ApplicationBorderBrush}"            
                        Margin="0,0,0,0"                               
                        ItemTemplate="{StaticResource TaskResumeTemplate}"
                        ItemsSource="{Binding}"
                        HorizontalContentAlignment="Stretch"                    
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled"  
                        ScrollViewer.VerticalScrollBarVisibility="Hidden"
                        ScrollViewer.CanContentScroll="False"
                        SelectionChanged="listView_SelectionChanged"                        
                        IsSynchronizedWithCurrentItem="True"
                        MouseUp="listView_MouseUp"     
                        TextBlock.Foreground="White"
                        MaxHeight="500">                
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Border Style="{StaticResource ListBoxItemBorder}">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <Border x:Name="border" Style="{StaticResource HighLightBorder}" Margin="2,2,2,0" Grid.Column="0">
                                                <ContentPresenter x:Name="content"  Margin="0,0,0,0"  />
                                            </Border>
                                            <TextBlock Grid.Column="1" FontSize="11" HorizontalAlignment="Right" Margin="0,-2,2,2" VerticalAlignment="Bottom">
                                                <Hyperlink Foreground="{StaticResource ExtraLightBrush}" Click="Hyperlink_Click">
                                                    <TextBlock Text="{x:Static props:Resources.Details}"/>
                                                </Hyperlink>
                                                <TextBlock.Style>
                                                    <Style>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding TaskUId}"  Value="00000000-0000-0000-0000-000000000000">
                                                                <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </TextBlock.Style>
                                            </TextBlock>
                                        </Grid>
                                        
                                    </Border>                                   
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>                    
                </ListBox.ItemContainerStyle>
                <ListBox.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>                    
                </ListBox.Resources>
            </ListBox>

            <BadHabit_Factory_Controls:SmartScroll Grid.Row="1" ScrollDirection="Up" PanelName="listView" RepeatButtonStyle="{StaticResource ScrollUpButton}" />
            <BadHabit_Factory_Controls:SmartScroll Grid.Row="1" ScrollDirection="Down" PanelName="listView" RepeatButtonStyle="{StaticResource ScrollDownButton}" />



            <Popup
                x:Name="workingToolTipPopUp"
                Focusable="False"
                PopupAnimation="Fade"                
                Placement="Top"
                AllowsTransparency="True"
                IsOpen="False"
                VerticalOffset="-3"                                
                IsHitTestVisible="False">
                <Border                    
                    x:Name="toolTipBorder"
                    MinWidth="300"
                    
                    IsHitTestVisible="False"
                    Background="{StaticResource TaskSelectorBackgroundBrush}"
                    CornerRadius="5"
                    BorderThickness="1,1,1,1"
                    BorderBrush="{StaticResource ApplicationBorderBrush}">
                    <TextBlock
                        Margin="4"
                        Padding="4"                        
                        MaxWidth="800"
                        MaxHeight="100"
                        FontSize="20"
                        Foreground="White"
                        TextWrapping="NoWrap"
                        Text="{Binding TaskName, StringFormat={x:Static props:Resources.Working_on_TASK}}"/>
                    
                </Border>
            </Popup>
                
            
        </Grid>
    </Border>

  
</Window>
